package com.xingfly.service;

import com.qiniu.common.Zone;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
import com.xingfly.util.WebConstant;
import org.springframework.stereotype.Service;

/**
 * 七牛云 上传 服务
 * Created by SuperS on 14/01/2017.
 */
@Service
public class UploadService {
    public long MAX_SIZE = WebConstant.FILE_MAX_SIZE;
    //    @Value("${qiniu.access.key}")
    private String ACCESS_KEY = "0ZFldeQZaHezSTbJhwg85hPJ3b-C2j24EgK6kJbM";
    //    @Value(("${qiniu.secret.key}"))
    private String SECRET_KEY = "BFha_WETDK7AlgN8v84AlWMeRfMhhv8HdKaqAy9n";
    //    @Value(("${qiniu.zone.name}"))
    public String ZONE_NAME = "xingfly";

    private Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
    private Zone zone = Zone.autoZone();
    private Configuration c = new Configuration(zone);
    private UploadManager uploadManager = new UploadManager(c);

    public String getUpToken() {
        return auth.uploadToken(ZONE_NAME, null, 3600, new StringMap());
    }

    public UploadManager getUploadManager() {
        return uploadManager;
    }


}
